/*
 *              Copyright (C) 2011 The MusicMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *            http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.musicmod.plugin.socialize.weibo;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPrefsUtils {

	public static boolean getBooleanPreference(Context context, String name,
			boolean def) {
		SharedPreferences prefs = context.getSharedPreferences(
				Constants.SHAREDPREFS_NAME, Context.MODE_PRIVATE);
		return prefs.getBoolean(name, def);
	}

	public static void setBooleanPreference(Context context, String name,
			boolean value) {
		SharedPreferences preferences = context.getSharedPreferences(
				Constants.SHAREDPREFS_NAME, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putBoolean(name, value);
		editor.commit();
	}

	public static String getStringPreference(Context context, String name,
			String def) {
		SharedPreferences prefs = context.getSharedPreferences(
				Constants.SHAREDPREFS_NAME, Context.MODE_PRIVATE);
		return prefs.getString(name, def);
	}

	public static void setStringPreference(Context context, String name,
			String value) {
		SharedPreferences preferences = context.getSharedPreferences(
				Constants.SHAREDPREFS_NAME, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putString(name, value);
		editor.commit();
	}

	public static long getLongPreference(Context context, String name, long def) {
		SharedPreferences prefs = context.getSharedPreferences(
				Constants.SHAREDPREFS_NAME, Context.MODE_PRIVATE);
		return prefs.getLong(name, def);
	}

	public static void setLongPreference(Context context, String name,
			long value) {
		SharedPreferences preferences = context.getSharedPreferences(
				Constants.SHAREDPREFS_NAME, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putLong(name, value);
		editor.commit();
	}
}